Existential any in Swift, and when it becomes required

The any keyword makes the cost of an existential type visible. Here is what a bare protocol name was hiding, where the migration actually stands today, and how to turn the warnings on early.

Codable errors are finally readable in Swift 6.3

DecodingError and EncodingError now print a clean one-line summary with the coding path, instead of the wall of text we used to skim past.

Typed throws in Swift 6

Swift 6 lets a function declare exactly which error type it throws. Here is the syntax, what it does to catch blocks, and why untyped throws is still the right default.

Trailing commas beyond arrays in Swift 6.1

Swift 6.1 allows a trailing comma in parameter lists, tuples, generic parameters, capture lists, and more. A small change that makes diffs a lot cleaner.

How to use if and switch as expressions in Swift

Swift 5.9 lets an if or switch produce a value instead of just assigning one. It removes a var we never wanted, but the single-expression rule catches people out.

How to add cases to a public enum without breaking your API

Adding a case to a public enum is a source-breaking change for anyone switching over it. Swift's @nonexhaustive attribute finally lets packages opt out of that.

How to declare a fixed-size array in Swift

Swift 6.2 adds InlineArray, a fixed-size array whose length is part of its type, along with a shorthand for writing it: [5 of Int].

How to set a default value in Swift string interpolation

Swift 6.2 adds a default: label to string interpolation, so we can provide a fallback string for any optional value without fighting the type checker.

How to use raw identifiers in Swift

Swift 6.2 lets us write names containing spaces, digits, and punctuation by wrapping them in backticks. Let's see where that helps.

Private properties no longer break the memberwise initializer in Swift 6.4

SE-0502 changes the rules for the synthesized memberwise initializer so a private property with an initial value doesn't make the whole initializer inaccessible.

How to declare a memberwise initializer in a Swift extension

SE-0546 proposes allowing us to declare a struct's memberwise initializer in a same-file extension. Let's see how it works.

See all tags.